/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.ridepad.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author ananthaamornphong
 */
@Entity
@Table(name = "cars")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Cars.findAll", query = "SELECT c FROM Cars c"),
    @NamedQuery(name = "Cars.findByEmail", query = "SELECT c FROM Cars c WHERE c.email = :email"),
    @NamedQuery(name = "Cars.findByModel", query = "SELECT c FROM Cars c WHERE c.model = :model"),
    @NamedQuery(name = "Cars.findByYear", query = "SELECT c FROM Cars c WHERE c.year = :year"),
    @NamedQuery(name = "Cars.findByMiles", query = "SELECT c FROM Cars c WHERE c.miles = :miles"),
    @NamedQuery(name = "Cars.findByMpg", query = "SELECT c FROM Cars c WHERE c.mpg = :mpg"),
    @NamedQuery(name = "Cars.findByMpg2", query = "SELECT c FROM Cars c WHERE c.mpg2 = :mpg2"),
    @NamedQuery(name = "Cars.findByPricepg", query = "SELECT c FROM Cars c WHERE c.pricepg = :pricepg"),
    @NamedQuery(name = "Cars.findByCartype", query = "SELECT c FROM Cars c WHERE c.cartype = :cartype")})
public class Cars implements Serializable {
    private static final long serialVersionUID = 1L;
    // @Pattern(regexp="[a-z0-9!#$%&'*+/=?^_`{|}~-]+(?:\\.[a-z0-9!#$%&'*+/=?^_`{|}~-]+)*@(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?", message="Invalid email")//if the field contains email address consider using this annotation to enforce field validation
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "email")
    private String email;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "model")
    private String model;
    @Size(max = 4)
    @Column(name = "year")
    private String year;
    @Size(max = 100)
    @Column(name = "miles")
    private String miles;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "mpg")
    private String mpg;
    @Size(max = 100)
    @Column(name = "mpg2")
    private String mpg2;
    @Size(max = 100)
    @Column(name = "pricepg")
    private String pricepg;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 100)
    @Column(name = "cartype")
    private String cartype;

    public Cars() {
    }

    public Cars(String email) {
        this.email = email;
    }

    public Cars(String email, String model, String mpg, String cartype) {
        this.email = email;
        this.model = model;
        this.mpg = mpg;
        this.cartype = cartype;
    }

    public String getEmail() {
        return email;
    }

    public void setEmail(String email) {
        this.email = email;
    }

    public String getModel() {
        return model;
    }

    public void setModel(String model) {
        this.model = model;
    }

    public String getYear() {
        return year;
    }

    public void setYear(String year) {
        this.year = year;
    }

    public String getMiles() {
        return miles;
    }

    public void setMiles(String miles) {
        this.miles = miles;
    }

    public String getMpg() {
        return mpg;
    }

    public void setMpg(String mpg) {
        this.mpg = mpg;
    }

    public String getMpg2() {
        return mpg2;
    }

    public void setMpg2(String mpg2) {
        this.mpg2 = mpg2;
    }

    public String getPricepg() {
        return pricepg;
    }

    public void setPricepg(String pricepg) {
        this.pricepg = pricepg;
    }

    public String getCartype() {
        return cartype;
    }

    public void setCartype(String cartype) {
        this.cartype = cartype;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (email != null ? email.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Cars)) {
            return false;
        }
        Cars other = (Cars) object;
        if ((this.email == null && other.email != null) || (this.email != null && !this.email.equals(other.email))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.ridepad.model.Cars[ email=" + email + " ]";
    }
    
}
